package cn.edu.sjtu.flaw_detection.util;

import cn.edu.sjtu.flaw_detection.dto.TaskDTO;
import cn.edu.sjtu.flaw_detection.enums.TaskStateEnum;
import cn.edu.sjtu.flaw_detection.vo.TaskVO;

public class TaskUtil {

  public static String genKey(TaskDTO taskDTO) {
    return taskDTO.getProcessId().concat(taskDTO.getTaskId());
  }

  public static boolean switchState(TaskVO taskVO, TaskStateEnum from, TaskStateEnum to) {
    if (taskVO == null || taskVO.getStatus() != from) {
      return false;
    }
    taskVO.setStatus(to);
    return true;
  }
}
